]> dgit.raspbian.org Git - dovecot.git/commit
[PATCH] lib-sieve: Enforce CPU time limit within :contains and :matches matcher loops
authorTimo Sirainen <timo.sirainen@open-xchange.com>
Sun, 19 Apr 2026 23:10:29 +0000 (23:10 +0000)
committerNoah Meyerhans <noahm@debian.org>
Wed, 16 Sep 2026 19:06:35 +0000 (15:06 -0400)
commit9813a2abdcc7376dde478b12ad274a6d9bdf10c9
treeacb5e4612dfb359b3878ff19a4dae1f35bedde50
parent209db83359d0d3a48782144ccb82d4f17d204750
[PATCH] lib-sieve: Enforce CPU time limit within :contains and :matches matcher loops

The naive O(N*M) substring search in mcht-contains.c and the naive find loop
in mcht-matches.c can run for hours on a large value (e.g. a message body),
completely bypassing sieve_max_cpu_time because that limit was only checked
between bytecode operations.

Expose the active CPU limit via sieve_runtime_cpu_limit_exceeded() and poll
it every 4096 inner iterations. When the limit is hit the match returns
SIEVE_EXEC_RESOURCE_LIMIT, matching the existing behavior at the bytecode
boundary. This is a minimal safety net ahead of switching the matchers to
algorithms that do not require it.

Gbp-Pq: Name CVE-2026-40016.patch
pigeonhole/src/lib-sieve/mcht-contains.c
pigeonhole/src/lib-sieve/mcht-matches.c
pigeonhole/src/lib-sieve/sieve-interpreter.c
pigeonhole/src/lib-sieve/sieve-interpreter.h